package tutorial;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import printing.BWCartridge;
import printing.ColorCartridge;
import printing.ContiniousPrinter;
import printing.ICartridge;
import printing.IMachine;
import printing.Machine;
import printing.Printer;
import printing.PrintingDevice;

public class HelloWorld {
	public static void main (String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
	{

		ContiniousPrinter cp = new ContiniousPrinter();
//		Thread thread = new Thread(cp);
//		thread.start();
		
		ExecutorService executor = Executors.newFixedThreadPool(10);
		executor.submit(cp);
		executor.submit(cp);
		executor.submit(cp);
		executor.submit(cp);
		executor.submit(cp);
		executor.submit(cp);
		executor.submit(cp);
		executor.shutdown();
		

		for (int i=0; i<100; i++)
			System.out.println("Main thread "+ i); 
		
	}
}
		




/* Annotations example
 * Printer<ColorCartridge> printer = new Printer<ColorCartridge>(true, "MY Printer ", ColorCartridge.BLUE);
printer.loadPaper(50);

PrintingDevice annotation =  printer.getClass().getAnnotation(PrintingDevice.class);
Method printMethod = printer.getClass().getMethod(annotation.defaultPrintMethod(), int.class);

printMethod.invoke(printer, annotation.defaultNumberOfCopies());

printer.outputPage(4);
*/
		
		
		
		
		
		
		
		
		
		
		
//		
//		Path path = Paths.get("D:\\newfile.txt");
//		
////		Creating a file
////		try
////		{
////			Files.createFile(path);
////		} catch (IOException e) {
////			e.printStackTrace();
////		}
//		
//		//Deleting a file
////		try
////		{
////			Files.deleteIfExists(path);
////		} catch (IOException e) {
////			e.printStackTrace();
////		}
////
////	}
	


/*// ENUM list iteration Ex.
 * printer.loadPaper(5);
//printer.print(5);
//printer.outputPage(1);
for (ColorCartridge cartridge : ColorCartridge.values())
{
	System.out.println(cartridge.printColor());
}
	*/






/* ENUM examples
 * 
 * switch (printer.getCartridge()) 
{
case BLUE:
	System.out.println("Blue");
	break;
case GREEN:
	System.out.println("Green");
	break;
case RED:
	System.out.println("Red");
	break;
case YELLOW:
	System.out.println("Yellow");
	break;
	

}*/









/* Map Collection example
 * 
 * Map<String, List<Integer>> testScores = new HashMap<String, List<Integer>>();

List<Integer> joeScores = new ArrayList<Integer>();
joeScores.add(88);
joeScores.add(80);
joeScores.add(99);
testScores.put("Joe", joeScores);

List<Integer> amyScores = new ArrayList<Integer>();
amyScores.add(11);
amyScores.add(22);
amyScores.add(33);
testScores.put("Amy", amyScores);

List<Integer> babScores = new ArrayList<Integer>();
babScores.add(40);
babScores.add(50);
babScores.add(60);
testScores.put("Bab", babScores);

printScores ("Amy", testScores);




}
private static void printScores(String studentName, Map<String, List<Integer>> scoresMap)
{
List<Integer> scores = scoresMap.get(studentName);
for (int score : scores)
{
	System.out.println(score);
}
}


*/

	
/* Exception handling example
 * 		Printer<BWCartridge> printer = new Printer<BWCartridge>(true, "MY Printer", new BWCartridge());
		try
		{
			printer.print(-1);	
		}
		catch (IllegalArgumentException exception)
		{
			System.out.println(exception.getLocalizedMessage());
			return;
		}
		finally 
		{
			printer.TurnOff();	
 */
	
	
	



	
	
	
	
/* Generics example
 * 	Printer<BWCartridge> printer = new Printer<BWCartridge>(true, "MY Printer", new BWCartridge());
//		Printer<ColorCartridge> printerCC = new Printer<ColorCartridge>(true, "MY Printer", new ColorCartridge());
//		printOne(printer);
//		printOne(printerCC);
//	}
//
//		public static void printOne(Printer<? extends ICartridge> printer)
//		{
//			String fillPercentage = printer.getCartridge().getFillPercentage();
//			System.out.println(fillPercentage);
//		}
*/		


